<?xml version="1.0" encoding="UTF-8" ?>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>  
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>      
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="../../../js/jquery.js"></script>
<script type="text/javascript" src="../../../js/jquery-ui-personalized.min.js"></script>
<script type="text/javascript" src="../js/common.js"></script>
<script type="text/javascript" src="../js/purchaseItem.js"></script>
<link type="text/css" href="../../../style/theme/ui.all.css" rel="stylesheet" />
<link type="text/css" href="../style/style.css" rel="stylesheet"/>
<title>购置单列表</title>
</head>
<body>
	<div class="ajaxMessage"></div>
	<h1>${student.dormitory.name }的购置单</h1>
	<div class="filterForm">
		<form action="purchaseItemList.do" method="get">
			<select name="type">
				<option value="dormitory">寝室</option>
			</select>
			<span>受理</span><span><input type="checkbox" name="processed"/></span>
			<span>处理</span><span><input type="checkbox" name="applied"/></span>
			<span>起始时间:</span><span><input type="text" name="fromDate" class="datepicker"/></span>
			<span>结束时间:</span><span><input type="text" name="toDate" class="datepicker"/></span>
			<input type="submit" name="submit" value="查询"/>
		</form>
	</div>
		<c:choose>
			<c:when test="${!empty purchaseItems.list}">
				<div>
					<input type="button" name="delete" value="删除"/>
				</div>
				<div title="查看/修改" class="modifyDialog">
					<form action="updatePurchaseItem" method="post" name="updatePurchaseItemForm">
						<input type="hidden" name="purchaseItemId"/>
						<p>
							<span>申请寝室:${student.dormitory.name }</span>
						</p>
						<p>
							<span>申请人:${student.realName }</span>
						</p>
						<div>
							<label for="title">*标题:</label>
							<div><input type="text" name="title" value=""/></div>
						</div>
						<div>
							<label for="description">*购买原因:</label>
							<div>
								<textarea cols="25" rows="7" name="description" ></textarea>
							</div>
						</div>
						<div>
							<label for="contactTel">*联系电话</label>
							<div><input type="text" name="contactTel" value="${student.account.telephone}"/></div>
						</div>
					</form>
				</div>	
				<table id="purchaseItems" border="1px">
					<thead>
						<tr>
							<th><input type="checkbox" name="checkAll"/></th>
							<th>ID</th>
							<th>标题</th>
							<th>原因</th>
							<th>申请人</th>
							<th>联系电话</th>
							<th>请求时间</th>
							<th>受理</th>
							<th>受理时间</th>
							<th>处理</th>
							<th>处理时间</th>
							<th>查看/修改</th>
						</tr>																		
					</thead>
					<tbody>
						<c:forEach items="${purchaseItems.list}" var="purchaseItem">
							<tr>
								<td>
									<input type="checkbox" name="item" value="${purchaseItem.id }"
									${purchaseItem.status.processed ? "disabled='disabled'" : "" }/>
								</td>
								<td title="id">${purchaseItem.id}</td>
								<td title="title">${purchaseItem.title }</td>
								<td title="description" >${purchaseItem.description }</td>
								<td title="student">${purchaseItem.student.realName }</td>
								<td title="contactTel">${purchaseItem.contactTel }</td>
								<td title="requestDate">
									<fmt:formatDate value="${purchaseItem.requestDate }" pattern="yyyy-MM-dd HH:mm"/>
								</td>
								<td title="processed">
									状态<input type="checkbox" name="processed"
										${purchaseItem.status.processed ? "checked=\"checked\"" : "" }
										disabled="disabled"/>
								</td>
								<td>
									<c:choose>
										<c:when test="${!empty purchaseItem.status.processDate}">
											<fmt:formatDate value="${purchaseItem.status.processDate}" pattern="yyyy-MM-dd HH:mm"/>
										</c:when>
										<c:otherwise>暂无</c:otherwise>
									</c:choose>											
								</td>
								<td>
									状态<input type="checkbox" name="applied" disabled="disabled"
										${purchaseItem.status.applied ? "checked='checked'" : "" }/>
								</td>
								<td>
									<c:choose>
										<c:when test="${!empty purchaseItem.status.applyDate}">
											<fmt:formatDate value="${purchaseItem.status.applyDate}" pattern="yyyy-MM-dd HH:mm"/>
										</c:when>
										<c:otherwise>暂无</c:otherwise>
									</c:choose>										
								</td>
								<td>
									<input type="button" name="modify" value="查看/修改"/>
								</td>
							</tr>
						</c:forEach>
					</tbody>
				</table>
				<div>
					<input type="button" name="delete" value="删除"/>
				</div>
			</c:when>
			<c:otherwise>
				<p>暂时没有找到符合条件的购置单</p>				
			</c:otherwise>
		</c:choose>
	</div>
</body>
</html>